.class Limoblife/applist/DatabaseItem;
.super Ljava/lang/Object;
.source "AppListActivity.java"


# static fields
.field private static sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;


# instance fields
.field private context:Landroid/content/Context;

.field private createTableSql:Ljava/lang/String;

.field public filedName:[Ljava/lang/String;

.field public filedType:[Ljava/lang/String;

.field public tableName:Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/content/Context;[[Ljava/lang/String;)V
    .locals 5
    .parameter "context"
    .parameter "tableInfo"

    .prologue
    const/4 v4, 0x1

    const/4 v3, 0x0

    .line 729
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 730
    iput-object p1, p0, Limoblife/applist/DatabaseItem;->context:Landroid/content/Context;

    .line 731
    aget-object v2, p2, v3

    aget-object v2, v2, v3

    iput-object v2, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    .line 732
    aget-object v2, p2, v4

    iput-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    .line 733
    const/4 v2, 0x2

    aget-object v2, p2, v2

    iput-object v2, p0, Limoblife/applist/DatabaseItem;->filedType:[Ljava/lang/String;

    .line 734
    new-instance v1, Ljava/lang/StringBuffer;

    const-string v2, "create table if not exists "

    invoke-direct {v1, v2}, Ljava/lang/StringBuffer;-><init>(Ljava/lang/String;)V

    .line 735
    .local v1, sb:Ljava/lang/StringBuffer;
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 736
    const-string v2, "("

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 737
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    array-length v2, v2

    if-lt v0, v2, :cond_0

    .line 743
    invoke-virtual {v1}, Ljava/lang/StringBuffer;->length()I

    move-result v2

    sub-int/2addr v2, v4

    const/16 v3, 0x29

    invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuffer;->setCharAt(IC)V

    .line 744
    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v2

    iput-object v2, p0, Limoblife/applist/DatabaseItem;->createTableSql:Ljava/lang/String;

    .line 745
    const/4 v1, 0x0

    .line 746
    return-void

    .line 738
    :cond_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    aget-object v2, v2, v0

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 739
    const-string v2, " "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 740
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedType:[Ljava/lang/String;

    aget-object v2, v2, v0

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 741
    const-string v2, ","

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 737
    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method public static final close()V
    .locals 1

    .prologue
    .line 823
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    if-eqz v0, :cond_0

    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->isOpen()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 824
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 826
    :cond_0
    return-void
.end method

.method private static final open(Landroid/content/Context;)V
    .locals 3
    .parameter "context"

    .prologue
    .line 818
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    if-eqz v0, :cond_0

    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->isOpen()Z

    move-result v0

    if-nez v0, :cond_1

    .line 819
    :cond_0
    const-string v0, "IMOBLIFEUPDATALIST"

    const/4 v1, 0x0

    const/4 v2, 0x0

    invoke-virtual {p0, v0, v1, v2}, Landroid/content/Context;->openOrCreateDatabase(Ljava/lang/String;ILandroid/database/sqlite/SQLiteDatabase$CursorFactory;)Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    sput-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    .line 821
    :cond_1
    return-void
.end method


# virtual methods
.method public final addSingleRecord([B[Ljava/lang/String;)V
    .locals 5
    .parameter "data"
    .parameter "record"

    .prologue
    .line 797
    invoke-virtual {p0}, Limoblife/applist/DatabaseItem;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    .line 798
    new-instance v0, Landroid/content/ContentValues;

    invoke-direct {v0}, Landroid/content/ContentValues;-><init>()V

    .line 799
    .local v0, contentValues:Landroid/content/ContentValues;
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    const/4 v3, 0x0

    aget-object v2, v2, v3

    invoke-virtual {v0, v2, p1}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V

    .line 800
    const/4 v1, 0x1

    .local v1, i:I
    :goto_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    array-length v2, v2

    if-lt v1, v2, :cond_0

    .line 803
    sget-object v2, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    iget-object v3, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    const/4 v4, 0x0

    invoke-virtual {v2, v3, v4, v0}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    .line 804
    invoke-virtual {v0}, Landroid/content/ContentValues;->clear()V

    .line 805
    return-void

    .line 801
    :cond_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    aget-object v2, v2, v1

    const/4 v3, 0x1

    sub-int v3, v1, v3

    aget-object v3, p2, v3

    invoke-virtual {v0, v2, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 800
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public final addSingleRecord([Ljava/lang/String;)V
    .locals 5
    .parameter "record"

    .prologue
    .line 788
    invoke-virtual {p0}, Limoblife/applist/DatabaseItem;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    .line 789
    new-instance v0, Landroid/content/ContentValues;

    invoke-direct {v0}, Landroid/content/ContentValues;-><init>()V

    .line 790
    .local v0, contentValues:Landroid/content/ContentValues;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    array-length v2, v2

    if-lt v1, v2, :cond_0

    .line 793
    sget-object v2, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    iget-object v3, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    const/4 v4, 0x0

    invoke-virtual {v2, v3, v4, v0}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    .line 794
    invoke-virtual {v0}, Landroid/content/ContentValues;->clear()V

    .line 795
    return-void

    .line 791
    :cond_0
    iget-object v2, p0, Limoblife/applist/DatabaseItem;->filedName:[Ljava/lang/String;

    aget-object v2, v2, v1

    aget-object v3, p1, v1

    invoke-virtual {v0, v2, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 790
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public final deleteSingleRecord(Ljava/lang/String;)V
    .locals 3
    .parameter "whereSql"

    .prologue
    .line 808
    invoke-virtual {p0}, Limoblife/applist/DatabaseItem;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    .line 809
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    iget-object v1, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    const/4 v2, 0x0

    invoke-virtual {v0, v1, p1, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    .line 810
    return-void
.end method

.method public final deleteTable()V
    .locals 3

    .prologue
    .line 813
    iget-object v0, p0, Limoblife/applist/DatabaseItem;->context:Landroid/content/Context;

    invoke-static {v0}, Limoblife/applist/DatabaseItem;->open(Landroid/content/Context;)V

    .line 814
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "DROP TABLE IF EXISTS "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v2, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    .line 815
    return-void
.end method

.method public final getDatabaseCursor()Landroid/database/Cursor;
    .locals 4

    .prologue
    .line 757
    invoke-virtual {p0}, Limoblife/applist/DatabaseItem;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    .line 759
    sget-object v1, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "select * from "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v3, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 760
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    .line 761
    return-object v0
.end method

.method public final getDatabaseCursor([Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    .locals 6
    .parameter "filedName"
    .parameter "conditions"

    .prologue
    .line 766
    invoke-virtual {p0}, Limoblife/applist/DatabaseItem;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    .line 767
    new-instance v2, Ljava/lang/StringBuffer;

    const-string v3, "select "

    invoke-direct {v2, v3}, Ljava/lang/StringBuffer;-><init>(Ljava/lang/String;)V

    .line 768
    .local v2, sb:Ljava/lang/StringBuffer;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    array-length v3, p1

    if-lt v1, v3, :cond_0

    .line 772
    invoke-virtual {v2}, Ljava/lang/StringBuffer;->length()I

    move-result v3

    const/4 v4, 0x1

    sub-int/2addr v3, v4

    const/16 v4, 0x20

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuffer;->setCharAt(IC)V

    .line 773
    const-string v3, "from "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 774
    iget-object v3, p0, Limoblife/applist/DatabaseItem;->tableName:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 775
    invoke-virtual {v2, p2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 777
    sget-object v3, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    invoke-virtual {v2}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v4

    const/4 v5, 0x0

    invoke-virtual {v3, v4, v5}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 779
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    .line 780
    const/4 v2, 0x0

    .line 784
    return-object v0

    .line 769
    .end local v0           #cursor:Landroid/database/Cursor;
    :cond_0
    aget-object v3, p1, v1

    invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 770
    const-string v3, ","

    invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 768
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public final getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;
    .locals 2

    .prologue
    .line 750
    iget-object v0, p0, Limoblife/applist/DatabaseItem;->context:Landroid/content/Context;

    invoke-static {v0}, Limoblife/applist/DatabaseItem;->open(Landroid/content/Context;)V

    .line 752
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    iget-object v1, p0, Limoblife/applist/DatabaseItem;->createTableSql:Ljava/lang/String;

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    .line 754
    sget-object v0, Limoblife/applist/DatabaseItem;->sqliteDatabase:Landroid/database/sqlite/SQLiteDatabase;

    return-object v0
.end method
